package com.ljt.kotlinandmvvm.main.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.ljt.kotlinandmvvm.R
import com.ljt.kotlinandmvvm.main.viewholder.ShoppingCartViewHolder

/**
 * @auther :lujiantao
 * @date :2024/5/4 11:59 AM
 * @desc :购物车适配器
 */
class ShoppingCartAdapter(private val list:ArrayList<String>): RecyclerView.Adapter<ShoppingCartViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ShoppingCartViewHolder {
        val itemView = LayoutInflater.from(parent.context).inflate(R.layout.item_shopping_cart,parent,false)
        return ShoppingCartViewHolder(itemView)
    }

    override fun onBindViewHolder(holder: ShoppingCartViewHolder, position: Int) {
        val str = list[position]
        with (holder){
            tvModuleCommandityName.text = str
        }
    }

    override fun getItemCount(): Int {
        return list.size
    }
}